package com.agilegroup.crm.adapters;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.agilegroup.crm.ui.fragments.AppointmentFragment;
import com.agilegroup.crm.ui.fragments.CallFragment;
import com.agilegroup.crm.ui.fragments.ViewLeadFragment;

public class MyFragmentPagerAdapter extends FragmentPagerAdapter{

	final int PAGE_COUNT = 3;
	
	public MyFragmentPagerAdapter(FragmentManager fm) {
		super(fm);
		// TODO Auto-generated constructor stub
	}

	/** This method will be invoked when a page is requested to create */
    @Override
    public Fragment getItem(int arg0) {
        Bundle data = new Bundle();
        switch(arg0){
            /** Android tab is selected */
            case 0:
                ViewLeadFragment viewLeadFragment = new ViewLeadFragment();
                data.putInt("current_page", arg0+1);
                viewLeadFragment.setArguments(data);
                return viewLeadFragment;
 
            /** Apple tab is selected */
            case 1:
                AppointmentFragment appointmentFragment = new AppointmentFragment();
                data.putInt("current_page", arg0+1);
                appointmentFragment.setArguments(data);
                return appointmentFragment;
                
            case 2:
                CallFragment callFragment = new CallFragment();
                data.putInt("current_page", arg0+1);
                callFragment.setArguments(data);
                return callFragment;
        }
        return null;
    }
 
    /** Returns the number of pages */
    @Override
    public int getCount() {
        return PAGE_COUNT;
    }
	
}
